<?php if (!defined('THINK_PATH')) exit();?><!doctype html>
<html lang="zh-cn">
<head>
    <meta charset="UTF-8"/>
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0"/>
    <title>长乐美食城-全部商品</title>
    <link rel="stylesheet" type="text/css" href="/Public/assets/home/images/favicon.ico">
    <link rel="stylesheet" type="text/css" href="/Public/vendor/slick/slick.css"/>
    <link rel="stylesheet" type="text/css" href="/Public/vendor/font-awesome/css/font-awesome.css"/>
    <link rel="stylesheet" type="text/css" href="/Public/assets/home/css/common.css"/>
</head>
<body>

<div class="logo">
    <h1><a href="index.html"><img class="img-responsive" src="/Public/assets/home/images/favicon.ico" alt="长乐美食城"/></a></h1>

    <h3>长乐美食城</h3>

    <div class="clears"></div>
</div>
<h3 style="width: 50%;
    text-align: center;
    line-height: 30px;
    color: #fff;
    font-weight: normal;
    background-color: #c06090;margin-top: 10px;">我的购物车</h3>

<form>
    <section class="cart">
        <dl class="good">
            <dt><img class="img-responsive" src="http://p0.meituan.net/msmerchant/56d513e3433ac4dbb288917160d90dd766375.jpg" alt="产品图片"></dt>
            <dd class="dd">
                <ul>
                    <li>热干面</li>
                    <li><span></span> <span class="price">￥4.00元</span></li>
                    <li>
                        <div class="btn-group">
                            <span class="sub"  type="button">－</span>
                            <input type="text" value="2" name="num" class="num">
                            <span class="add"  type="button">＋</span>
                        </div>
                        <a class="btn-cart-omit" href="javascript:void(0);">移除</a>
                    </li>
                </ul>
            </dd>
        </dl>

        <p id="total">总金额：<span></span> <span id="total-price">￥8.00元</span></p>

        <input class="submit" type="submit" value="我要购买"/>
    </section>
</form>


<div class="footer">
    <p>
        <a href="">商城首页</a>
        <a href="">购物车</a>
        <a href="">会员中心</a>
    </p>

    <dl>
        <dt><a href="javascript:void(0);"><img class="img-responsive" src="/Public/assets/home/images/favicon.ico" alt="长乐美食城" /></a></dt>
        <dd><a href="javascript:void(0);">武汉长乐未央网络科技有限公司提供技术支持</a></dd>
    </dl>
</div>

<script type="text/javascript" src="/Public/assets/home/js/jquery.min.js"></script>
<script>
    $(function() {
        $(".add").click(function() {
//            alert(111232);
            var t = $(this).parent().find('input[class*=num]');
//            console.log(t);return false;
            t.val(parseInt(t.val()) + 1)
            setTotal();
        })
        $(".sub").click(function() {
            var t = $(this).parent().find('input[class*=num]');
            t.val(parseInt(t.val()) - 1)
            if(parseInt(t.val()) < 1) {
                t.val(1);
            }
            setTotal();
        })
//        $(".text").keypress(function(){
//            var t = $(this).parent().find('input[class*=num]');
//            if(parseInt(t.val())==""||undefined||null || isNaN(t.val())) {
//                t.val(1);
//            }
//            setTotal();
//        })
        function setTotal() {
            var s = 0;
            $(".dd ul li").each(function() {
                var t = $(this).find('input[class*=num]').val();
                var p = $(this).find('span[class*=price]').text();
                s += parseInt(t) * parseFloat(p);
            });
            $("#total").html(s.toFixed(2));
        }
        setTotal();
    })
</script>
</body>
</html>